<#include "/java_copyright.include">
<#assign className = table.className>
<#assign classNameLower = className?uncap_first>
package ${basepackage}.util;
import java.lang.reflect.Field;

public class MethodUtil {
    /**
     * 将一个对象里所有的空值属性设置成null
     * @param o
     * @return
     */
    public static void convertEmptyToNull(Object o){
        Class c=o.getClass();
        try {
            Field[] fs=c.getDeclaredFields();
            for (Field f : fs) {
                f.setAccessible(true);
                Object obj = f.get(o);
                if(obj != null){
                    String str = obj.toString().replaceAll(" ", "");
                    if("".equals(str)){
                        f.set(o, null);
                    }
                }
            }
        }catch (SecurityException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
